﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="product-brand.aspx.cs" Inherits="FJERP.product_brand" %>

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>供应商列表</title>
</head>
<body>
    <form runat="server">
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户中心 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span style="margin-left:400px;font-size:30px;font-family:华文行楷" id="tck">商品报损</span></div>
    	<div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">报损/ 报溢查询</a></span> 
        <span class="l" style="margin-left:50px;font-family:华文行楷;font-size:18px">单据类型:<select id="Select1" onchange="por()" class="input-text">
        <option>商品报损</option>
        <option>商品报溢</option>
    </select></span> 
            <span class="l" style="margin-left:50px;font-family:华文行楷;font-size:18px">仓库类型:
             <asp:DropDownList ID="DropDownList1" runat="server" class="input-text"></asp:DropDownList>
            </span>
            <span class="l" style="margin-left:50px;font-family:华文行楷;font-size:18px" id="lor">报损日期:
            </span><input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})" id="datemin" class="input-text Wdate" style="width:120px;">
            
    	</div>
    	<div class="mt-20">
    	<span class="l" ><a class="btn btn-primary radius" data-title="搜索" onclick="Hui_admin_tab()" href="javascript:;">搜索</a><input type="text" name="" id="Product_Name" placeholder="商品名称" style="width:140px" class="input-text"></span>
            <span>
                <label style="margin-left:50px;font-family:华文行楷;font-size:18px">备注：</label>
                <input type="text" name="" id="Document_Remark" placeholder="备注" style="width:140px" class="input-text">
            </span>
            <span>
                <label style="margin-left:50px;font-family:华文行楷;font-size:18px">单号：</label>
                <span id="number"><%=Session["number"] %></span>
            </span>
            </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort" id="table">
		<thead>
			<tr class="text-c">
			   <th>商品名称</th>
				<th>规格型号</th>
				<th>进价</th>
				<th>商品类别</th>
                <th>生产厂商</th>
                <th>数量</th>
                <th>总金额</th>
			</tr>
		</thead>
		<tbody>
          
		</tbody>
	</table>
	</div>
    <div class="mt-20">
        <span class="r" style="margin-right:280px;"><a class="btn btn-primary radius" data-title="确认" onclick="Hui_admin_add()" href="javascript:;">确认</a></span><span class="l" style="margin-left:50px;font-family:华文行楷;font-size:18px">经办人:
             <asp:DropDownList ID="DropDownList2" runat="server" class="input-text"></asp:DropDownList>
            </span>
        </div>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
        <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
        <script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
        <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="js/H-ui.js"></script>
        <script type="text/javascript" src="js/H-ui.admin.js"></script>
        </form> 
</body>
</html>
<script>
    function por() {
        var ss = $("#Select1 option:selected").val();
        $("#tck").html(ss);
        if (ss == "商品报损")
        {
            $("#lor").html("报损日期:");
        }
        else
        {
            $("#lor").html("报溢日期:");
        }
        
    }
   
    function datadel() {

        location.href = "product_brand_Show.aspx";

    }
    function Hui_admin_tab(){

        var Product_Name = $("#Product_Name").val();
        alert(Product_Name);
        $.ajax({
            type: "post",
            url: "Handler/Product.ashx",
            data: {
                action:"brand",
                Product_Name: Product_Name,
            },
            success: function (data1) {
                var data = eval(data1);
                for (var i in data) {
                    var pp = "<tr class='text-c' id='P" + data[i].Product_Id + "'><input id='P" + data[i].Product_Id + "' type='hidden'  value='" + data[i].Product_Id + "' name='ck'/><td>" + data[i].Product_Name + "</td><td>" + data[i].Product_Modelspe + "</td><td  id='price" + data[i].Product_Id + "' name='price'>" + data[i].Product_Price + "</td><td>" + data[i].Product_Type_Name + "</td><td>" + data[i].Product_frim + "</td><td><input id='num" + data[i].Product_Id + "' type='text'  style='width:100px;' onchange='fun1(" + data[i].Product_Id + ")' name='num' /></td><td><span id='SumMoney" + data[i].Product_Id + "' name='SumMoney'>0</span>元</td></tr>";
                    if ($("#P" + data[i].Product_Id + "").length > 0) {
                        alert("已存在");
                        return;
                    }
                    else {
                        $("#table tbody").append(pp);
                    }

                }
            }
        })


    }
    function Hui_admin_add() {
        var ss = $("#Select1 option:selected").val();
      
        var WareHose_Id = $("#DropDownList1 option:selected").val();
      
        var Document_Date = $("#datemin").val();
    
        var Employee_Id = $("#DropDownList2 option:selected").val();
        var Document_Remark = $("#Document_Remark").val();
        var Product_Id = new Array();
        var i = -1;
        $("[name='ck']").each(function () {
            i++;
            Product_Id[i] = $(this).val();

        })
        var PurchaseMate_Num = new Array();
        var p = -1;
        $("[name='num']").each(function () {
            p++;
            PurchaseMate_Num[p] = $(this).val();
        })
     
        var PurchaseMate_Price = new Array();
        var r = -1;
        $("[name='SumMoney']").each(function () {
            r++;
            PurchaseMate_Price[r] = $(this).html();

        })
        var Document_Mate_Price = new Array();
        var s = -1;
        $("[name='price']").each(function () {
            s++;
            Document_Mate_Price[s] = $(this).html();

        })
        //字符拼接XML;
        var xml = "<mm>"
        for (var i = 0; i < $("[name='num']").length; i++) {
            xml += "<xx Product_Id='" + Product_Id[i] + "' Document_Mate_Num='" + PurchaseMate_Num[i] + "' Document_Mate_Price='" + Document_Mate_Price[i] + "' Document_Mate_SumPrice='" + PurchaseMate_Price[i] + "' />";

        }
        xml += "</mm>"
        var encodexml = encodeURIComponent(xml);
        var sumM = 0;
        $("[name='SumMoney']").each(function () {

            sumM += parseInt($(this).html());
        })
        $.ajax({
            type: "post",
            url: "Handler/Product.ashx",
            data: {
                action: "Document",
                WareHose_Id: WareHose_Id,
                Employee_Id: Employee_Id,
                Document_Remark: Document_Remark,
                Document_Date: Document_Date,
                Document_Type_Name: ss,
                Document_num: $("#number").html(),
                xml: encodexml
            },
            success: function (data) {
                if (data > 0) {
                    alert("OK");
                }
                else {
                    alert("No");
                }

            },
            error: function () {

                alert("Game over")
            }
        })
    }
    function fun1(id) {
        var num = $("#num" + id + "").val();
        var price = $("#price" + id + "").html();
        var sum = num * price;
        $("#SumMoney" + id + "").html(sum);

    }
</script>
